import { _decorator, Component, Node,AudioClip, AudioSource } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AudioManager')
export class AudioManager extends Component {
    @property({type: AudioClip})
    public clickClip: AudioClip = null!; // 绑定音效

    private audioSource: AudioSource = null!; // 音频资源
    start() {
        this.audioSource = this.getComponent(AudioSource); // 获取当前节点的音频组件
    }

    update(deltaTime: number) {
        
    }

    // 播放音效
    playSound(){
        // 以指定音量倍数播放一个音频一次
        this.audioSource.playOneShot(this.clickClip, 0.5);
    }
}


